package com.ouc.dcrms.video;

import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;

/*****************************************************************************
 * 类 ：JDialogSerialCfg 
 * 类描述 ：串口参数配置,串口透传
 ****************************************************************************/
public class JDialogSerialCfg extends JDialog {
    private static final long serialVersionUID = -8653132519329835956L;

    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;
    private NativeLong m_lUserID;// 用户ID
    private HCNetSDK.NET_DVR_RS232CFG_V30 m_strRs232Cfg;// 232串口信息
    private HCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo;// 设备信息
    private HCNetSDK.NET_DVR_DECODERCFG_V30 m_stru485DecoderCfg;// 485解码参数结构
    private HCNetSDK.NET_DVR_PTZCFG m_struPtzCfg;// ptz参数,用来获取解码器类型
    private boolean b485Initialed;// 485串口是否已初始化
    private NativeLong m_lSerialHandle;// NET_DVR_SerialStart()的返回值 ,串口发送句柄
    private FSerialDataCallBack fSerialDataCallBack;// 报警回调函数

    /*************************************************
     * 函数: JDialogSerialCfg 
     * 函数描述: 构造函数 Creates new form JDialogSerialCfg
     *************************************************/
    public JDialogSerialCfg(java.awt.Frame parent, boolean modal,
	    NativeLong lUserID, HCNetSDK.NET_DVR_DEVICEINFO_V30 strDeviceInfo) {
	super(parent, modal);
	m_lUserID = lUserID;
	m_strDeviceInfo = strDeviceInfo;
	b485Initialed = false;
	m_lSerialHandle = new NativeLong(-1);
	initComponents();

	// 初始化232panel
	initial232();
	// 初始化485anel
	initial485();

	// 初始化通道号组合框
	for (int i = 0; i < m_strDeviceInfo.byChanNum; i++) {
	    jComboBoxChannelNumber.addItem("通道"
		    + (i + m_strDeviceInfo.byStartChan));
	}
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed"
    // desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

	jTabbedPane1 = new JTabbedPane();
	jPanel232 = new JPanel();
	jPanel9 = new JPanel();
	jLabel36 = new JLabel();
	jComboBoxPPPMode = new JComboBox<Object>();
	jLabel37 = new JLabel();
	jComboBoxRedialMode = new JComboBox<Object>();
	jLabel38 = new JLabel();
	jTextFieldUserName = new JTextField();
	jLabel39 = new JLabel();
	jLabel41 = new JLabel();
	jTextFieldRemoteIP = new JTextField();
	jLabel42 = new JLabel();
	jTextFieldLocalIP = new JTextField();
	jLabel43 = new JLabel();
	jTextFieldMask = new JTextField();
	jLabel44 = new JLabel();
	jTextFieldTelNumber = new JTextField();
	jCheckBoxSecret = new JCheckBox();
	jCheckBoxRedial = new JCheckBox();
	jPasswordFieldPassword = new JPasswordField();
	jButtonSetup232 = new JButton();
	jButtonExit1 = new JButton();
	jPanel7 = new JPanel();
	jComboBox232Rate = new JComboBox<Object>();
	jComboBox232DataBit = new JComboBox<Object>();
	jComboBox232StopBit = new JComboBox<Object>();
	jComboBox232CheckBit = new JComboBox<Object>();
	jComboBox232Flow = new JComboBox<Object>();
	jLabel5 = new JLabel();
	jLabel4 = new JLabel();
	jLabel3 = new JLabel();
	jLabel2 = new JLabel();
	jLabel1 = new JLabel();
	jComboBoxOperateMode = new JComboBox<Object>();
	jLabel6 = new JLabel();
	jPanel485 = new JPanel();
	jButtonSetup485 = new JButton();
	jButtonExit2 = new JButton();
	jPanel10 = new JPanel();
	jComboBox485Channel = new JComboBox<Object>();
	jLabel16 = new JLabel();
	jPanel6 = new JPanel();
	jComboBox485Rate = new JComboBox<Object>();
	jLabel19 = new JLabel();
	jComboBox485Flow = new JComboBox<Object>();
	jComboBox485StopBit = new JComboBox<Object>();
	jLabel22 = new JLabel();
	jTextFieldDecodeAddress = new JTextField();
	jComboBoxDecodeType = new JComboBox<Object>();
	jLabel23 = new JLabel();
	jLabel17 = new JLabel();
	jLabel18 = new JLabel();
	jLabel20 = new JLabel();
	jComboBox485CheckBit = new JComboBox<Object>();
	jComboBox485DataBit = new JComboBox<Object>();
	jLabel21 = new JLabel();
	jPanel3 = new JPanel();
	jPanel2 = new JPanel();
	jLabel24 = new JLabel();
	jLabel25 = new JLabel();
	jComboBoxSerialType = new JComboBox<Object>();
	jComboBoxChannelNumber = new JComboBox<Object>();
	jPanel4 = new JPanel();
	jTextFieldSendData = new JTextField();
	jLabel26 = new JLabel();
	jComboBoxSendInterface = new JComboBox<Object>();
	jButtonSend = new JButton();
	jPanel5 = new JPanel();
	jScrollPane1 = new JScrollPane();
	jTextAreaMessage = new JTextArea();
	jButtonCreate = new JButton();
	jButtonDistruct = new JButton();
	jButtonExit3 = new JButton();

	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	setTitle("串口参数配置");

	jPanel232.setLayout(null);

	jPanel9.setBorder(BorderFactory.createTitledBorder("窄带传输电话拨号配置"));

	jLabel36.setText("PPP模式");

	jComboBoxPPPMode.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "主动", "被动" }));

	jLabel37.setText("回拨模式");

	jComboBoxRedialMode.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "拨入者指定", "预置回拨号" }));

	jLabel38.setText("用户名");

	jLabel39.setText("密码");

	jLabel41.setText("远端IP");

	jLabel42.setText("本地IP");

	jLabel43.setText("IP掩码");

	jLabel44.setText("电话号码");

	jCheckBoxSecret.setText("数据加密");

	jCheckBoxRedial.setText("回拨");

	jPasswordFieldPassword.setText("jPasswordField1");

	GroupLayout jPanel9Layout = new GroupLayout(jPanel9);
	jPanel9.setLayout(jPanel9Layout);
	jPanel9Layout
		.setHorizontalGroup(jPanel9Layout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanel9Layout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addGroup(
								jPanel9Layout
									.createSequentialGroup()
									.addGroup(
										jPanel9Layout
											.createParallelGroup(
												GroupLayout.Alignment.TRAILING)
											.addGroup(
												GroupLayout.Alignment.LEADING,
												jPanel9Layout
													.createSequentialGroup()
													.addComponent(
														jLabel38)
													.addPreferredGap(
														LayoutStyle.ComponentPlacement.UNRELATED)
													.addComponent(
														jTextFieldUserName,
														GroupLayout.DEFAULT_SIZE,
														99,
														Short.MAX_VALUE))
											.addGroup(
												GroupLayout.Alignment.LEADING,
												jPanel9Layout
													.createSequentialGroup()
													.addComponent(
														jLabel36)
													.addPreferredGap(
														LayoutStyle.ComponentPlacement.RELATED)
													.addComponent(
														jComboBoxPPPMode,
														0,
														99,
														Short.MAX_VALUE)
													.addPreferredGap(
														LayoutStyle.ComponentPlacement.RELATED))
											.addGroup(
												GroupLayout.Alignment.LEADING,
												jPanel9Layout
													.createSequentialGroup()
													.addGroup(
														jPanel9Layout
															.createParallelGroup(
																GroupLayout.Alignment.TRAILING,
																false)
															.addComponent(
																jLabel43,
																GroupLayout.Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
															.addComponent(
																jLabel41,
																GroupLayout.Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
													.addPreferredGap(
														LayoutStyle.ComponentPlacement.UNRELATED)
													.addGroup(
														jPanel9Layout
															.createParallelGroup(
																GroupLayout.Alignment.TRAILING)
															.addComponent(
																jTextFieldMask,
																GroupLayout.DEFAULT_SIZE,
																99,
																Short.MAX_VALUE)
															.addComponent(
																jTextFieldRemoteIP,
																GroupLayout.Alignment.LEADING,
																GroupLayout.DEFAULT_SIZE,
																99,
																Short.MAX_VALUE))))
									.addGap(33,
										33,
										33))
							.addGroup(
								jPanel9Layout
									.createSequentialGroup()
									.addComponent(
										jCheckBoxSecret,
										GroupLayout.PREFERRED_SIZE,
										82,
										GroupLayout.PREFERRED_SIZE)
									.addGap(96,
										96,
										96)))
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addGroup(
								jPanel9Layout
									.createSequentialGroup()
									.addComponent(
										jCheckBoxRedial,
										GroupLayout.PREFERRED_SIZE,
										58,
										GroupLayout.PREFERRED_SIZE)
									.addGap(138,
										138,
										138))
							.addGroup(
								jPanel9Layout
									.createSequentialGroup()
									.addGroup(
										jPanel9Layout
											.createParallelGroup(
												GroupLayout.Alignment.LEADING)
											.addComponent(
												jLabel39)
											.addComponent(
												jLabel42)
											.addComponent(
												jLabel44)
											.addComponent(
												jLabel37))
									.addGap(23,
										23,
										23)
									.addGroup(
										jPanel9Layout
											.createParallelGroup(
												GroupLayout.Alignment.TRAILING)
											.addComponent(
												jComboBoxRedialMode,
												0,
												96,
												Short.MAX_VALUE)
											.addComponent(
												jTextFieldTelNumber,
												GroupLayout.Alignment.LEADING,
												GroupLayout.DEFAULT_SIZE,
												96,
												Short.MAX_VALUE)
											.addComponent(
												jTextFieldLocalIP,
												GroupLayout.Alignment.LEADING,
												GroupLayout.DEFAULT_SIZE,
												96,
												Short.MAX_VALUE)
											.addComponent(
												jPasswordFieldPassword,
												GroupLayout.Alignment.LEADING,
												GroupLayout.DEFAULT_SIZE,
												96,
												Short.MAX_VALUE))
									.addGap(29,
										29,
										29)))));
	jPanel9Layout
		.setVerticalGroup(jPanel9Layout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanel9Layout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(jLabel38)
							.addComponent(
								jTextFieldUserName,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
							.addComponent(jLabel39)
							.addComponent(
								jPasswordFieldPassword,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE))
					.addGap(10, 10, 10)
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(jLabel36)
							.addComponent(
								jComboBoxPPPMode,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
							.addComponent(jLabel37)
							.addComponent(
								jComboBoxRedialMode,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(jLabel41)
							.addComponent(
								jTextFieldRemoteIP,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
							.addComponent(jLabel42)
							.addComponent(
								jTextFieldLocalIP,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(
								jTextFieldMask,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
							.addComponent(jLabel44)
							.addComponent(
								jTextFieldTelNumber,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
							.addComponent(jLabel43))
					.addGap(18, 18, 18)
					.addGroup(
						jPanel9Layout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(
								jCheckBoxSecret)
							.addComponent(
								jCheckBoxRedial))
					.addContainerGap()));

	jPanel232.add(jPanel9);
	jPanel9.setBounds(20, 130, 400, 200);

	jButtonSetup232.setText("设置");
	jButtonSetup232.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonSetup232ActionPerformed(evt);
	    }
	});
	jPanel232.add(jButtonSetup232);
	jButtonSetup232.setBounds(30, 360, 57, 23);

	jButtonExit1.setText("退出");
	jButtonExit1.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonExit1ActionPerformed(evt);
	    }
	});
	jPanel232.add(jButtonExit1);
	jButtonExit1.setBounds(330, 360, 70, 23);

	jPanel7.setBorder(new LineBorder(new java.awt.Color(51, 51, 255), 1,
		true));
	jPanel7.setLayout(null);

	jComboBox232Rate.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "50", "75", "110", "150", "300", "600", "1200",
			"2400", "4800", "9600", "19200", "38400", "57600",
			"76800", "115.2k" }));
	jPanel7.add(jComboBox232Rate);
	jComboBox232Rate.setBounds(20, 40, 70, 21);

	jComboBox232DataBit.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "5", "6", "7", "8" }));
	jPanel7.add(jComboBox232DataBit);
	jComboBox232DataBit.setBounds(100, 40, 50, 21);

	jComboBox232StopBit.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "1", "2" }));
	jPanel7.add(jComboBox232StopBit);
	jComboBox232StopBit.setBounds(180, 40, 50, 21);

	jComboBox232CheckBit.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "无校验", "奇校验", "偶校验" }));
	jPanel7.add(jComboBox232CheckBit);
	jComboBox232CheckBit.setBounds(260, 40, 62, 21);

	jComboBox232Flow.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "无", "软流控", "硬流控" }));
	jPanel7.add(jComboBox232Flow);
	jComboBox232Flow.setBounds(340, 40, 62, 21);

	jLabel5.setText("流控");
	jPanel7.add(jLabel5);
	jLabel5.setBounds(340, 10, 40, 15);

	jLabel4.setText("校验");
	jPanel7.add(jLabel4);
	jLabel4.setBounds(260, 10, 40, 15);

	jLabel3.setText("停止位");
	jPanel7.add(jLabel3);
	jLabel3.setBounds(180, 10, 50, 15);

	jLabel2.setText("数据位");
	jPanel7.add(jLabel2);
	jLabel2.setBounds(100, 10, 50, 15);

	jLabel1.setText("速率");
	jPanel7.add(jLabel1);
	jLabel1.setBounds(20, 10, 40, 15);

	jComboBoxOperateMode.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "窄带传输", "控制台", "透明通道" }));
	jPanel7.add(jComboBoxOperateMode);
	jComboBoxOperateMode.setBounds(100, 80, 100, 21);

	jLabel6.setText("操作模式");
	jPanel7.add(jLabel6);
	jLabel6.setBounds(20, 80, 60, 15);

	jPanel232.add(jPanel7);
	jPanel7.setBounds(10, 10, 420, 330);

	jTabbedPane1.addTab("232串口配置", jPanel232);

	jPanel485.setLayout(null);

	jButtonSetup485.setText("设置当前通道");
	jButtonSetup485.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonSetup485ActionPerformed(evt);
	    }
	});
	jPanel485.add(jButtonSetup485);
	jButtonSetup485.setBounds(30, 360, 120, 23);

	jButtonExit2.setText("退出");
	jButtonExit2.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonExit2ActionPerformed(evt);
	    }
	});
	jPanel485.add(jButtonExit2);
	jButtonExit2.setBounds(280, 360, 57, 23);

	jPanel10.setBorder(new LineBorder(new java.awt.Color(0, 70, 213), 1,
		true));

	jComboBox485Channel
		.addActionListener(new java.awt.event.ActionListener() {
		    public void actionPerformed(java.awt.event.ActionEvent evt) {
			jComboBox485ChannelActionPerformed(evt);
		    }
		});

	jLabel16.setText("通道号");

	jPanel6.setBorder(new LineBorder(new java.awt.Color(153, 153, 153), 1,
		true));
	jPanel6.setLayout(null);

	jComboBox485Rate.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "50", "75", "110", "150", "300", "600", "1200",
			"2400", "4800", "9600", "19200", "38400", "57600",
			"76800", "115.2k" }));
	jPanel6.add(jComboBox485Rate);
	jComboBox485Rate.setBounds(90, 30, 70, 21);

	jLabel19.setText("停止位");
	jPanel6.add(jLabel19);
	jLabel19.setBounds(30, 80, 50, 15);

	jComboBox485Flow.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "无", "软流控", "硬流控" }));
	jPanel6.add(jComboBox485Flow);
	jComboBox485Flow.setBounds(270, 80, 70, 21);

	jComboBox485StopBit.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "1", "2" }));
	jPanel6.add(jComboBox485StopBit);
	jComboBox485StopBit.setBounds(90, 80, 70, 21);

	jLabel22.setText("解码器类型");
	jPanel6.add(jLabel22);
	jLabel22.setBounds(30, 170, 70, 15);
	jPanel6.add(jTextFieldDecodeAddress);
	jTextFieldDecodeAddress.setBounds(120, 210, 100, 21);

	jPanel6.add(jComboBoxDecodeType);
	jComboBoxDecodeType.setBounds(120, 170, 100, 21);

	jLabel23.setText("解码器地址");
	jPanel6.add(jLabel23);
	jLabel23.setBounds(30, 210, 70, 15);

	jLabel17.setText("速率");
	jPanel6.add(jLabel17);
	jLabel17.setBounds(30, 30, 40, 15);

	jLabel18.setText("数据位");
	jPanel6.add(jLabel18);
	jLabel18.setBounds(210, 30, 50, 15);

	jLabel20.setText("校验");
	jPanel6.add(jLabel20);
	jLabel20.setBounds(30, 130, 40, 15);

	jComboBox485CheckBit.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "无校验", "奇校验", "偶校验" }));
	jPanel6.add(jComboBox485CheckBit);
	jComboBox485CheckBit.setBounds(90, 130, 70, 21);

	jComboBox485DataBit.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "5", "6", "7", "8" }));
	jPanel6.add(jComboBox485DataBit);
	jComboBox485DataBit.setBounds(270, 30, 70, 21);

	jLabel21.setText("流控");
	jPanel6.add(jLabel21);
	jLabel21.setBounds(210, 80, 50, 15);

	GroupLayout jPanel10Layout = new GroupLayout(jPanel10);
	jPanel10.setLayout(jPanel10Layout);
	jPanel10Layout
		.setHorizontalGroup(jPanel10Layout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanel10Layout
					.createSequentialGroup()
					.addGroup(
						jPanel10Layout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addGroup(
								jPanel10Layout
									.createSequentialGroup()
									.addGap(25,
										25,
										25)
									.addComponent(
										jLabel16)
									.addGap(42,
										42,
										42)
									.addComponent(
										jComboBox485Channel,
										GroupLayout.PREFERRED_SIZE,
										73,
										GroupLayout.PREFERRED_SIZE))
							.addGroup(
								jPanel10Layout
									.createSequentialGroup()
									.addContainerGap()
									.addComponent(
										jPanel6,
										GroupLayout.PREFERRED_SIZE,
										400,
										GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(18, Short.MAX_VALUE)));
	jPanel10Layout.setVerticalGroup(jPanel10Layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addGroup(
		jPanel10Layout
			.createSequentialGroup()
			.addContainerGap()
			.addGroup(
				jPanel10Layout
					.createParallelGroup(
						GroupLayout.Alignment.BASELINE)
					.addComponent(jLabel16)
					.addComponent(jComboBox485Channel,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE))
			.addGap(18, 18, 18)
			.addComponent(jPanel6, GroupLayout.PREFERRED_SIZE, 250,
				GroupLayout.PREFERRED_SIZE)
			.addContainerGap(29, Short.MAX_VALUE)));

	jPanel485.add(jPanel10);
	jPanel10.setBounds(10, 20, 430, 330);

	jTabbedPane1.addTab("RS485配置", jPanel485);

	jPanel2.setBorder(new LineBorder(new java.awt.Color(51, 51, 255), 1,
		true));

	jLabel24.setText("串口类型");

	jLabel25.setText("通道号");

	jComboBoxSerialType.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "232", "485" }));

	GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
	jPanel2.setLayout(jPanel2Layout);
	jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addGroup(
		jPanel2Layout
			.createSequentialGroup()
			.addGap(29, 29, 29)
			.addComponent(jLabel24)
			.addGap(18, 18, 18)
			.addComponent(jComboBoxSerialType,
				GroupLayout.PREFERRED_SIZE, 56,
				GroupLayout.PREFERRED_SIZE)
			.addGap(29, 29, 29)
			.addComponent(jLabel25)
			.addGap(18, 18, 18)
			.addComponent(jComboBoxChannelNumber,
				GroupLayout.PREFERRED_SIZE, 79,
				GroupLayout.PREFERRED_SIZE)
			.addContainerGap(114, Short.MAX_VALUE)));
	jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addGroup(
		jPanel2Layout
			.createSequentialGroup()
			.addGap(21, 21, 21)
			.addGroup(
				jPanel2Layout
					.createParallelGroup(
						GroupLayout.Alignment.BASELINE)
					.addComponent(jLabel24)
					.addComponent(jComboBoxSerialType,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
					.addComponent(jLabel25)
					.addComponent(jComboBoxChannelNumber,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE))
			.addContainerGap(GroupLayout.DEFAULT_SIZE,
				Short.MAX_VALUE)));

	jPanel4.setBorder(BorderFactory.createTitledBorder("发送数据"));

	jLabel26.setText("发送接口");

	jComboBoxSendInterface.setModel(new DefaultComboBoxModel<Object>(
		new String[] { "NET_DVR_SerialSend",
			"NET_DVR_SendToSerialPort", "NET_DVR_SendTo232Port" }));

	jButtonSend.setText("发送");
	jButtonSend.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonSendActionPerformed(evt);
	    }
	});

	GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
	jPanel4.setLayout(jPanel4Layout);
	jPanel4Layout.setHorizontalGroup(jPanel4Layout
		.createParallelGroup(GroupLayout.Alignment.LEADING)
		.addGroup(
			jPanel4Layout
				.createSequentialGroup()
				.addComponent(jTextFieldSendData,
					GroupLayout.DEFAULT_SIZE, 403,
					Short.MAX_VALUE).addContainerGap())
		.addGroup(
			jPanel4Layout
				.createSequentialGroup()
				.addContainerGap()
				.addComponent(jLabel26,
					GroupLayout.PREFERRED_SIZE, 56,
					GroupLayout.PREFERRED_SIZE)
				.addGap(18, 18, 18)
				.addComponent(jComboBoxSendInterface,
					GroupLayout.PREFERRED_SIZE, 190,
					GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(
					LayoutStyle.ComponentPlacement.RELATED,
					49, Short.MAX_VALUE)
				.addComponent(jButtonSend,
					GroupLayout.PREFERRED_SIZE, 70,
					GroupLayout.PREFERRED_SIZE)
				.addGap(20, 20, 20)));
	jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addGroup(
		jPanel4Layout
			.createSequentialGroup()
			.addContainerGap()
			.addComponent(jTextFieldSendData,
				GroupLayout.PREFERRED_SIZE,
				GroupLayout.DEFAULT_SIZE,
				GroupLayout.PREFERRED_SIZE)
			.addGap(18, 18, 18)
			.addGroup(
				jPanel4Layout
					.createParallelGroup(
						GroupLayout.Alignment.BASELINE)
					.addComponent(jButtonSend)
					.addComponent(jComboBoxSendInterface,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
					.addComponent(jLabel26))
			.addContainerGap(GroupLayout.DEFAULT_SIZE,
				Short.MAX_VALUE)));

	jPanel5.setBorder(BorderFactory.createTitledBorder("接收内容"));

	jTextAreaMessage.setColumns(20);
	jTextAreaMessage.setLineWrap(true);
	jTextAreaMessage.setRows(5);
	jTextAreaMessage.setWrapStyleWord(true);
	jScrollPane1.setViewportView(jTextAreaMessage);

	GroupLayout jPanel5Layout = new GroupLayout(jPanel5);
	jPanel5.setLayout(jPanel5Layout);
	jPanel5Layout.setHorizontalGroup(jPanel5Layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addComponent(jScrollPane1,
		GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE));
	jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addComponent(jScrollPane1,
		GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 139,
		Short.MAX_VALUE));

	jButtonCreate.setText("建立通道");
	jButtonCreate.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonCreateActionPerformed(evt);
	    }
	});

	jButtonDistruct.setText("停止通道");
	jButtonDistruct.setEnabled(false);
	jButtonDistruct.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonDistructActionPerformed(evt);
	    }
	});

	jButtonExit3.setText("退出");
	jButtonExit3.addActionListener(new java.awt.event.ActionListener() {
	    public void actionPerformed(java.awt.event.ActionEvent evt) {
		jButtonExit3ActionPerformed(evt);
	    }
	});

	GroupLayout jPanel3Layout = new GroupLayout(jPanel3);
	jPanel3.setLayout(jPanel3Layout);
	jPanel3Layout
		.setHorizontalGroup(jPanel3Layout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanel3Layout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
						jPanel3Layout
							.createParallelGroup(
								GroupLayout.Alignment.LEADING)
							.addGroup(
								jPanel3Layout
									.createSequentialGroup()
									.addComponent(
										jPanel5,
										GroupLayout.DEFAULT_SIZE,
										GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE)
									.addContainerGap())
							.addGroup(
								jPanel3Layout
									.createSequentialGroup()
									.addComponent(
										jPanel2,
										GroupLayout.DEFAULT_SIZE,
										GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE)
									.addContainerGap())
							.addGroup(
								jPanel3Layout
									.createSequentialGroup()
									.addGap(10,
										10,
										10)
									.addComponent(
										jButtonCreate)
									.addGap(41,
										41,
										41)
									.addComponent(
										jButtonDistruct)
									.addPreferredGap(
										LayoutStyle.ComponentPlacement.RELATED,
										123,
										Short.MAX_VALUE)
									.addComponent(
										jButtonExit3,
										GroupLayout.PREFERRED_SIZE,
										70,
										GroupLayout.PREFERRED_SIZE)
									.addGap(33,
										33,
										33))
							.addGroup(
								jPanel3Layout
									.createSequentialGroup()
									.addComponent(
										jPanel4,
										GroupLayout.DEFAULT_SIZE,
										GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE)
									.addContainerGap()))));
	jPanel3Layout
		.setVerticalGroup(jPanel3Layout
			.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addGroup(
				jPanel3Layout
					.createSequentialGroup()
					.addContainerGap()
					.addComponent(jPanel2,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jPanel4,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jPanel5,
						GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(
						LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(
						jPanel3Layout
							.createParallelGroup(
								GroupLayout.Alignment.BASELINE)
							.addComponent(
								jButtonCreate)
							.addComponent(
								jButtonDistruct)
							.addComponent(
								jButtonExit3))
					.addContainerGap(17, Short.MAX_VALUE)));

	jTabbedPane1.addTab("数据透传", jPanel3);

	GroupLayout layout = new GroupLayout(getContentPane());
	getContentPane().setLayout(layout);
	layout.setHorizontalGroup(layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addComponent(jTabbedPane1,
		GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE));
	layout.setVerticalGroup(layout.createParallelGroup(
		GroupLayout.Alignment.LEADING).addComponent(jTabbedPane1,
		GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE));

	pack();
    }// </editor-fold>//GEN-END:initComponents

    /*************************************************
     * 函数: "退出" 按钮单击响应函数 函数描述: 销毁对话框
     *************************************************/
    private void jButtonExit1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonExit1ActionPerformed
	this.dispose();
    }// GEN-LAST:event_jButtonExit1ActionPerformed

    /*************************************************
     * 函数: 232 "设置" 按钮单击响应函数 函数描述: 设置232配置参数
     *************************************************/
    private void jButtonSetup232ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonSetup232ActionPerformed
	m_strRs232Cfg.struRs232.dwBaudRate = jComboBox232Rate
		.getSelectedIndex();
	m_strRs232Cfg.struRs232.byDataBit = (byte) jComboBox232DataBit
		.getSelectedIndex();
	m_strRs232Cfg.struRs232.byStopBit = (byte) jComboBox232StopBit
		.getSelectedIndex();
	m_strRs232Cfg.struRs232.byParity = (byte) jComboBox232CheckBit
		.getSelectedIndex();
	m_strRs232Cfg.struRs232.byFlowcontrol = (byte) jComboBox232Flow
		.getSelectedIndex();
	m_strRs232Cfg.struRs232.dwWorkMode = jComboBoxOperateMode
		.getSelectedIndex();
	// ppp配置信息
	m_strRs232Cfg.struPPPConfig.sUsername = (jTextFieldUserName.getText() + "\0")
		.getBytes();
	m_strRs232Cfg.struPPPConfig.sPassword = (new String(
		jPasswordFieldPassword.getPassword()) + "\0").getBytes();
	m_strRs232Cfg.struPPPConfig.struRemoteIP.sIpV4 = (jTextFieldRemoteIP
		.getText() + "\0").getBytes();
	m_strRs232Cfg.struPPPConfig.struLocalIP.sIpV4 = (jTextFieldLocalIP
		.getText() + "\0").getBytes();
	m_strRs232Cfg.struPPPConfig.sLocalIPMask = (jTextFieldMask.getText() + "\0")
		.getBytes();
	m_strRs232Cfg.struPPPConfig.sTelephoneNumber = (jTextFieldTelNumber
		.getText() + "\0").getBytes();

	m_strRs232Cfg.struPPPConfig.byPPPMode = (byte) jComboBoxPPPMode
		.getSelectedIndex();
	m_strRs232Cfg.struPPPConfig.byRedialMode = (byte) jComboBoxRedialMode
		.getSelectedIndex();
	m_strRs232Cfg.struPPPConfig.byDataEncrypt = (byte) (jCheckBoxSecret
		.isSelected() ? 1 : 0);
	m_strRs232Cfg.struPPPConfig.byRedial = (byte) (jCheckBoxRedial
		.isSelected() ? 1 : 0);

	m_strRs232Cfg.write();
	Pointer lpConfig = m_strRs232Cfg.getPointer();
	boolean setDVRConfigSuc = hCNetSDK.NET_DVR_SetDVRConfig(m_lUserID,
		HCNetSDK.NET_DVR_SET_RS232CFG_V30, new NativeLong(0), lpConfig,
		m_strRs232Cfg.size());
	m_strRs232Cfg.read();
	if (setDVRConfigSuc != true) {
	    JOptionPane.showMessageDialog(this, "设置232串口配置失败");
	    return;
	} else {
	    JOptionPane.showMessageDialog(this, "设置232串口配置成功");
	}
    }// GEN-LAST:event_jButtonSetup232ActionPerformed

    /*************************************************
     * 函数: 485 "通道号" 选项改变响应函数 函数描述: 获取并显示对应通道的参数
     *************************************************/
    private void jComboBox485ChannelActionPerformed(
	    java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jComboBox485ChannelActionPerformed
	if (b485Initialed) {
	    int iChannelNumber = jComboBox485Channel.getSelectedIndex()
		    + m_strDeviceInfo.byStartChan;
	    IntByReference ibrBytesReturned = new IntByReference(0);
	    boolean getDVRConfigSuc = false;
	    m_stru485DecoderCfg = new HCNetSDK.NET_DVR_DECODERCFG_V30();
	    m_stru485DecoderCfg.write();
	    Pointer lpConfig = m_stru485DecoderCfg.getPointer();
	    getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID,
		    HCNetSDK.NET_DVR_GET_DECODERCFG_V30, new NativeLong(
			    iChannelNumber), lpConfig, m_stru485DecoderCfg
			    .size(), ibrBytesReturned);
	    m_stru485DecoderCfg.read();
	    if (getDVRConfigSuc != true) {
		JOptionPane.showMessageDialog(this, "获取485串口参数失败");
		return;
	    }
	    jComboBox485Rate.setSelectedIndex(m_stru485DecoderCfg.dwBaudRate);
	    jComboBox485DataBit.setSelectedIndex(m_stru485DecoderCfg.byDataBit);
	    jComboBox485StopBit.setSelectedIndex(m_stru485DecoderCfg.byStopBit);
	    jComboBox485Flow
		    .setSelectedIndex(m_stru485DecoderCfg.byFlowcontrol);
	    jComboBox485CheckBit.setSelectedIndex(m_stru485DecoderCfg.byParity);
	    jComboBoxDecodeType
		    .setSelectedIndex(m_stru485DecoderCfg.wDecoderType);
	    jTextFieldDecodeAddress.setText(m_stru485DecoderCfg.wDecoderAddress
		    + "");
	}
    }// GEN-LAST:event_jComboBox485ChannelActionPerformed

    /*************************************************
     * 函数: 485 "设置" 按钮单击响应函数 函数描述: 设置相应485通道配置参数
     *************************************************/
    private void jButtonSetup485ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonSetup485ActionPerformed
	int iChannelNumber = jComboBox485Channel.getSelectedIndex()
		+ m_strDeviceInfo.byStartChan;
	m_stru485DecoderCfg.dwBaudRate = jComboBox485Rate.getSelectedIndex();
	m_stru485DecoderCfg.byDataBit = (byte) jComboBox485DataBit
		.getSelectedIndex();
	m_stru485DecoderCfg.byStopBit = (byte) jComboBox485StopBit
		.getSelectedIndex();
	m_stru485DecoderCfg.byParity = (byte) jComboBox485CheckBit
		.getSelectedIndex();
	m_stru485DecoderCfg.byFlowcontrol = (byte) jComboBox485Flow
		.getSelectedIndex();
	m_stru485DecoderCfg.wDecoderType = (short) jComboBoxDecodeType
		.getSelectedIndex();
	m_stru485DecoderCfg.wDecoderAddress = (short) Integer
		.parseInt(jTextFieldDecodeAddress.getText());

	m_stru485DecoderCfg.write();
	Pointer lpConfig = m_stru485DecoderCfg.getPointer();
	boolean setDVRConfigSuc = hCNetSDK.NET_DVR_SetDVRConfig(m_lUserID,
		HCNetSDK.NET_DVR_SET_DECODERCFG_V30, new NativeLong(
			iChannelNumber), lpConfig, m_stru485DecoderCfg.size());
	m_stru485DecoderCfg.read();
	if (setDVRConfigSuc != true) {
	    JOptionPane.showMessageDialog(this, "设置485串口参数失败");
	    return;
	} else {
	    JOptionPane.showMessageDialog(this, "设置485串口参数成功");
	}
    }// GEN-LAST:event_jButtonSetup485ActionPerformed

    /*************************************************
     * 函数: 数据透传 "发送" 按钮单击响应函数 函数描述: 发送数据
     *************************************************/
    private void jButtonSendActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonSendActionPerformed
	int iSendInterface = jComboBoxSendInterface.getSelectedIndex(); // 发送的接口
	int iSelSerialIndex = jComboBoxChannelNumber.getSelectedIndex() + 1;// 串口通道号
	int iSerialType = jComboBoxSerialType.getSelectedIndex() + 1;// 串口类型

	NativeLong lSerialChan = new NativeLong(-1);// 串口通道号
	if (iSerialType == 0) {
	    // 232串口作为透明通道时该值设置为0
	    lSerialChan = new NativeLong(0);
	} else {
	    if (iSerialType == 1) {
		// 使用485串口时有效，从1开始
		lSerialChan = new NativeLong(iSelSerialIndex);
	    }
	}

	String sMessage = new String(jTextFieldSendData.getText());// 要发送的消息

	if (iSendInterface == 0) {
	    if (m_lSerialHandle.intValue() == -1) {
		JOptionPane.showMessageDialog(this, "请先建立透明通道");
		return;
	    }
	    if (!hCNetSDK.NET_DVR_SerialSend(m_lSerialHandle, lSerialChan,
		    sMessage, sMessage.length())) {
		JOptionPane.showMessageDialog(this, "发送失败");
		return;
	    }
	} else {
	    if (iSendInterface == 1) {
		if (!hCNetSDK.NET_DVR_SendToSerialPort(m_lUserID, iSerialType,
			iSelSerialIndex, sMessage, sMessage.length())) {
		    JOptionPane.showMessageDialog(this, "发送失败");
		    return;
		}
	    }
	}
    }// GEN-LAST:event_jButtonSendActionPerformed

    /*************************************************
     * 函数: "退出" 按钮单击响应函数 函数描述: 销毁对话框
     *************************************************/
    private void jButtonExit3ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonExit3ActionPerformed
	dispose();
    }// GEN-LAST:event_jButtonExit3ActionPerformed

    /*************************************************
     * 函数: 数据透传 "建立通道" 按钮单击响应函数 函数描述: 建立透明通道
     *************************************************/
    private void jButtonCreateActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonCreateActionPerformed
	int iSerialType = jComboBoxSerialType.getSelectedIndex() + 1;// 串口类型

	m_lSerialHandle = hCNetSDK.NET_DVR_SerialStart(m_lUserID,
		new NativeLong(iSerialType), fSerialDataCallBack, 0);
	if (m_lSerialHandle.intValue() == -1) {
	    JOptionPane.showMessageDialog(this, "建立透明通道失败!");
	    System.out.println(hCNetSDK.NET_DVR_GetLastError());
	    return;
	} else {
	    JOptionPane.showMessageDialog(this, "建立透明通道成功建立!");
	    jButtonCreate.setEnabled(false);
	    jButtonDistruct.setEnabled(true);
	}
    }// GEN-LAST:event_jButtonCreateActionPerformed

    /*************************************************
     * 函数: 数据透传 "停止通道" 按钮单击响应函数 函数描述: 停止透明通道
     *************************************************/
    private void jButtonDistructActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonDistructActionPerformed
	if (m_lSerialHandle.intValue() != -1) {
	    if (!hCNetSDK.NET_DVR_SerialStop(m_lSerialHandle)) {
		JOptionPane.showMessageDialog(this, "停止透明通道失败!");
		return;
	    } else {
		JOptionPane.showMessageDialog(this, "停止透明通道成功!");
		jButtonCreate.setEnabled(true);
		jButtonDistruct.setEnabled(false);
	    }
	}
    }// GEN-LAST:event_jButtonDistructActionPerformed

    private void jButtonExit2ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonExit2ActionPerformed
	dispose();
    }// GEN-LAST:event_jButtonExit2ActionPerformed

    /*************************************************
     * 函数: initial232 函数描述: 初始化232panel
     *************************************************/
    private void initial232() {
	IntByReference ibrBytesReturned = new IntByReference(0);
	boolean getDVRConfigSuc = false;
	m_strRs232Cfg = new HCNetSDK.NET_DVR_RS232CFG_V30();
	m_strRs232Cfg.write();
	Pointer lpConfig = m_strRs232Cfg.getPointer();
	getDVRConfigSuc = hCNetSDK.NET_DVR_GetDVRConfig(m_lUserID,
		HCNetSDK.NET_DVR_GET_RS232CFG_V30, new NativeLong(0), lpConfig,
		m_strRs232Cfg.size(), ibrBytesReturned);
	m_strRs232Cfg.read();
	if (getDVRConfigSuc != true) {
	    JOptionPane.showMessageDialog(this, "获取232串口参数失败");
	    return;
	}
	jComboBox232Rate.setSelectedIndex(m_strRs232Cfg.struRs232.dwBaudRate);
	jComboBox232DataBit.setSelectedIndex(m_strRs232Cfg.struRs232.byDataBit);
	jComboBox232StopBit.setSelectedIndex(m_strRs232Cfg.struRs232.byStopBit);
	jComboBox232CheckBit.setSelectedIndex(m_strRs232Cfg.struRs232.byParity);
	jComboBox232Flow
		.setSelectedIndex(m_strRs232Cfg.struRs232.byFlowcontrol);
	jComboBoxOperateMode
		.setSelectedIndex(m_strRs232Cfg.struRs232.dwWorkMode);

	// ppp配置信息
	String[] s = new String[2];
	s = new String(m_strRs232Cfg.struPPPConfig.sUsername).split("\0", 2);
	jTextFieldUserName.setText(s[0]);

	s = new String(m_strRs232Cfg.struPPPConfig.sPassword).split("\0", 2);
	jPasswordFieldPassword.setText(s[0]);

	s = new String(m_strRs232Cfg.struPPPConfig.struRemoteIP.sIpV4).split(
		"\0", 2);
	jTextFieldRemoteIP.setText(s[0]);

	s = new String(m_strRs232Cfg.struPPPConfig.struLocalIP.sIpV4).split(
		"\0", 2);
	jTextFieldLocalIP.setText(s[0]);

	s = new String(m_strRs232Cfg.struPPPConfig.sLocalIPMask).split("\0", 2);
	jTextFieldMask.setText(s[0]);

	s = new String(m_strRs232Cfg.struPPPConfig.sTelephoneNumber).split(
		"\0", 2);
	jTextFieldTelNumber.setText(s[0]);

	jComboBoxPPPMode
		.setSelectedIndex(m_strRs232Cfg.struPPPConfig.byPPPMode);
	jComboBoxRedialMode
		.setSelectedIndex(m_strRs232Cfg.struPPPConfig.byRedialMode);

	jCheckBoxSecret
		.setSelected((m_strRs232Cfg.struPPPConfig.byDataEncrypt == 1) ? true
			: false);
	jCheckBoxRedial
		.setSelected((m_strRs232Cfg.struPPPConfig.byRedial == 1) ? true
			: false);
    }

    /*************************************************
     * 函数: initial485 函数描述: 初始化485panel
     *************************************************/
    private void initial485() {
	for (int i = 0; i < m_strDeviceInfo.byChanNum; i++) {
	    jComboBox485Channel.addItem("通道"
		    + (i + m_strDeviceInfo.byStartChan));
	}

	// 获取ptz参数,初始化解码器类型组合框
	m_struPtzCfg = new HCNetSDK.NET_DVR_PTZCFG();
	if (!hCNetSDK.NET_DVR_GetPTZProtocol(m_lUserID, m_struPtzCfg)) {
	    JOptionPane.showMessageDialog(this, "获取PTZ参数失败");
	    return;
	}
	String[] s = new String[2];
	for (int i = 0; i < m_struPtzCfg.dwPtzNum; i++) {
	    s = new String(m_struPtzCfg.struPtz[i].byDescribe).split("\0", 2);
	    jComboBoxDecodeType.addItem(s[0]);
	}

	b485Initialed = true;
	jComboBox485Channel.setSelectedIndex(0);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private JButton jButtonCreate;
    private JButton jButtonDistruct;
    private JButton jButtonExit1;
    private JButton jButtonExit2;
    private JButton jButtonExit3;
    private JButton jButtonSend;
    private JButton jButtonSetup232;
    private JButton jButtonSetup485;
    private JCheckBox jCheckBoxRedial;
    private JCheckBox jCheckBoxSecret;
    private JComboBox<Object> jComboBox232CheckBit;
    private JComboBox<Object> jComboBox232DataBit;
    private JComboBox<Object> jComboBox232Flow;
    private JComboBox<Object> jComboBox232Rate;
    private JComboBox<Object> jComboBox232StopBit;
    private JComboBox<Object> jComboBox485Channel;
    private JComboBox<Object> jComboBox485CheckBit;
    private JComboBox<Object> jComboBox485DataBit;
    private JComboBox<Object> jComboBox485Flow;
    private JComboBox<Object> jComboBox485Rate;
    private JComboBox<Object> jComboBox485StopBit;
    private JComboBox<Object> jComboBoxChannelNumber;
    private JComboBox<Object> jComboBoxDecodeType;
    private JComboBox<Object> jComboBoxOperateMode;
    private JComboBox<Object> jComboBoxPPPMode;
    private JComboBox<Object> jComboBoxRedialMode;
    private JComboBox<Object> jComboBoxSendInterface;
    private JComboBox<Object> jComboBoxSerialType;
    private JLabel jLabel1;
    private JLabel jLabel16;
    private JLabel jLabel17;
    private JLabel jLabel18;
    private JLabel jLabel19;
    private JLabel jLabel2;
    private JLabel jLabel20;
    private JLabel jLabel21;
    private JLabel jLabel22;
    private JLabel jLabel23;
    private JLabel jLabel24;
    private JLabel jLabel25;
    private JLabel jLabel26;
    private JLabel jLabel3;
    private JLabel jLabel36;
    private JLabel jLabel37;
    private JLabel jLabel38;
    private JLabel jLabel39;
    private JLabel jLabel4;
    private JLabel jLabel41;
    private JLabel jLabel42;
    private JLabel jLabel43;
    private JLabel jLabel44;
    private JLabel jLabel5;
    private JLabel jLabel6;
    private JPanel jPanel10;
    private JPanel jPanel2;
    private JPanel jPanel232;
    private JPanel jPanel3;
    private JPanel jPanel4;
    private JPanel jPanel485;
    private JPanel jPanel5;
    private JPanel jPanel6;
    private JPanel jPanel7;
    private JPanel jPanel9;
    private JPasswordField jPasswordFieldPassword;
    private JScrollPane jScrollPane1;
    private JTabbedPane jTabbedPane1;
    private JTextArea jTextAreaMessage;
    private JTextField jTextFieldDecodeAddress;
    private JTextField jTextFieldLocalIP;
    private JTextField jTextFieldMask;
    private JTextField jTextFieldRemoteIP;
    private JTextField jTextFieldSendData;
    private JTextField jTextFieldTelNumber;
    private JTextField jTextFieldUserName;

    // End of variables declaration//GEN-END:variables

    /******************************************************************************
     * 内部类: FSerialDataCallBack 串口信息回调函数
     ******************************************************************************/
    class FSerialDataCallBack implements HCNetSDK.FSerialDataCallBack {

	public void invoke(NativeLong lSerialHandle, String pRecvDataBuffer,
		int dwBufSize, int dwUser) {
	    // 获取时间,格式化输出
	    Date today = new Date();
	    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

	    // 打印时间到jTextAreaMessage
	    jTextAreaMessage.append(dateFormat.format(today) + ":\n");
	    // 打印回调的信息到jTextAreaMessage
	    jTextAreaMessage.append(pRecvDataBuffer + "\n");
	}
    }
}
